﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using SPIWareMVVM.ViewModels;
using System.Windows;
using System.Windows.Controls;

namespace SPIWareMVVM.Views.Commands
{
    public class ShowCustomerListCommand : BaseCommand
    {
        ApplicationViewModel _sender { get; set; }

        public ShowCustomerListCommand(BaseViewModel sender)
            : base(sender)
        {
            //_sender = (ApplicationViewModel)sender;
        }

        public override void Execute(object parameter)
        {
            if (parameter != null && parameter.GetType() == typeof(CustomerList))
            {
                CustomerList list = (CustomerList)parameter;
                if (list != null)
                {
                    list.lbCustomers.SelectedIndex = -1;

                    if (mainWindow == null) mainWindow = (Window1)Window.GetWindow((CustomerList)list);
                    ApplicationData.ClearSelected(ApplicationData.AllSelectable);
                    mainWindow.HideLists();

                    mainWindow.customersList.Visibility = Visibility.Visible;
                }
            }
        }
    }
}
